package com.service.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.service.dao.model.Member;
import com.service.dao.po.MemberJAHRPo;
import com.service.dao.po.MemberJAPo;
import com.service.dao.query.JARecordPara;
import com.service.dao.model.JournalAccount;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Set;

public interface JournalAccountMapper extends BaseMapper<JournalAccount> {

	/**
	 * 获取会员累计收益
	 *
	 * @param memberId
	 * @param typeList
	 * @return
	 */
	BigDecimal getAccumulatedIncome(@Param("memberId") Integer memberId, @Param("typeList") List<Integer> typeList, @Param("outTime") Date outTime);

	List<JournalAccount> listTotalAccumulatedIncome(@Param("memberId") Integer memberId,
	                                                @Param("typeList") List<Integer> typeList,
	                                                @Param("startTime") Date startTime,
	                                                @Param("endTime") Date endTime);

	/**
	 * 统计订单是否产生收益
	 *
	 * @return
	 */
	@Select("select sum(ja_num) from hm_journal_account where coins_id = #{coinsId} and order_id = #{orderId}")
	BigDecimal checkByOrderId(@Param("coinsId") Integer coinsId, @Param("orderId") Integer orderId);


	/**
	 * 获取某时间段的某币种收益
	 *
	 * @return
	 */
	List<JournalAccount> getSomeTimeIncome(@Param("coinsId") Integer coinsId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

	/**
	 * 获取某天的收益
	 *
	 * @return
	 */
	BigDecimal getSomedayIncome(@Param("memberId") Integer memberId, @Param("typeList") List<Integer> typeList, @Param("someday") String someday);

	List<JournalAccount> listAccumulatedIncome(@Param("memberId") Integer memberId, @Param("typeList") List<Integer> typeList);

	List<JournalAccount> listMemberJA(@Param("coinsName") String coinsName, @Param("memberId") Integer memberId);

	List<MemberJAPo> listMemberJA4Admin(@Param("recordPara") JARecordPara recordPara);

	List<MemberJAHRPo> listJAHR4Admin(@Param("recordPara") JARecordPara recordPara);

	BigDecimal getSomedayTotalStatement(@Param("storeId") Integer storeId, @Param("typeList") List<Integer> typeList, @Param("someday") String someday);

	BigDecimal getSomedayTotalStatementByCoins(@Param("memberId") Integer memberId, @Param("coinsName") String coinsName, @Param("typeList") List<Integer> typeList, @Param("someday") String someday);

	BigDecimal getTotalStatementByCoins(@Param("memberId") Integer memberId, @Param("coinsName") String coinsName, @Param("typeList") List<Integer> typeList);

	BigDecimal getMemberTeamSomedayTotalStatementByCoins(@Param("memberList") List<Member> memberList, @Param("coinsName") String coinsName, @Param("typeList") List<Integer> typeList, @Param("someday") String someday);

	/**
	 * @Description: 统计用户流水总量
	 * @Author: ty
	 * @Date: 2021/4/30 15:38
	 * @param: [memberId, typeList]
	 * @return: java.math.BigDecimal
	 **/
	BigDecimal totalMemberStatement(@Param("memberId") Integer memberId, @Param("typeList") List<Integer> typeList, @Param("someday") String someday);

	/**
	 * @Description: 统计本月业绩 排除代理商和分公司伞下业绩
	 * @Author: ty
	 * @Date: 2021/5/6 15:36
	 * @param: [memberIds, currentMonth]
	 * @return: java.math.BigDecimal
	 **/
	BigDecimal totalPerformanceCurrentMonth(@Param("memberIds") Set<Integer> memberIds, @Param("typeList") List<Integer> typeList, @Param("currentMonth") String currentMonth);

	/**
	 * 统计某种类型某天的累计数量
	 * @param someDay
	 * @param typeList
	 * @return
	 */
	BigDecimal totalStatementByParam(@Param("someDay")String someDay,@Param("typeList") List<Integer> typeList);

	/**
	 * @Description: 判断用户的某天某流水是否存在
	 * @Author: ty
	 * @Date: 2021/5/28 14:17
	 * @param: [memberId, someday, typeList]
	 * @return: java.lang.Integer
	 **/
	Integer checkByMemberAndTypeAndSomeday(@Param("memberId")Integer memberId,@Param("someday")String someday,@Param("typeList") List<Integer> typeList);

	Integer checkByMemberAndTypeAndOrderAndSomeday(@Param("memberId")Integer memberId,@Param("orderId") Integer orderId,@Param("someday")String someday,@Param("typeList") List<Integer> typeList);

	/**
	 * @Description: 统计全网某一天的所有释放数量
	 * @Author: ty
	 * @Date: 2021/4/28 11:10
	 * @param: [typeList, coin, someday]
	 * @return: java.math.BigDecimal
	 **/
	BigDecimal totalAllNetworkSomeDayReleaseNum(@Param("typeList") List<Integer> typeList,
												@Param("coinsName") String coinsName,
												@Param("someday") String someday);
}